package com.binest.inclusionExamine.controller;



import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.core.page.TableDataInfo;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.inclusionExamine.domain.InclusionExamine;
import com.binest.inclusionExamine.service.IInclusionExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 收录审核Controller
 * 
 * @author binest
 * @date 2024-01-04
 */
@RestController
@RequestMapping("/inclusionExamine")
public class InclusionExamineController extends BaseController
{
    @Autowired
    private IInclusionExamineService inclusionExamineService;



    /**
     * 查询收录审核列表
     */
    @GetMapping("/list")
    public TableDataInfo list(InclusionExamine inclusionExamine)
    {
        startPage();
        List<InclusionExamine> list = inclusionExamineService.selectInclusionExamineList(inclusionExamine);
        return getDataTable(list);
    }


    @GetMapping("/myList")
    public TableDataInfo myList(InclusionExamine inclusionExamine)
    {
        TableDataInfo list = inclusionExamineService.selectMyInclusionExamineList(inclusionExamine);
        return list;
    }
    /**
     * 导出收录审核列表
     */

    @PostMapping("/export")
    public void export(HttpServletResponse response, InclusionExamine inclusionExamine)
    {
        List<InclusionExamine> list = inclusionExamineService.selectInclusionExamineList(inclusionExamine);
        ExcelUtil<InclusionExamine> util = new ExcelUtil<InclusionExamine>(InclusionExamine.class);
        util.exportExcel(response, list, "收录审核数据");
    }

    /**
     * 获取收录审核详细信息
     */
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo(String id)
    {
        return success(inclusionExamineService.selectInclusionExamineById(id));
    }

    /**
     * 新增收录审核
     */

    @PostMapping("/add")
    public AjaxResult add(@RequestBody InclusionExamine inclusionExamine)
    {
        return toAjax(inclusionExamineService.insertInclusionExamine(inclusionExamine));
    }

    /**
     * 修改收录审核
     */

    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody InclusionExamine inclusionExamine)
    {
        return toAjax(inclusionExamineService.updateInclusionExamine(inclusionExamine));
    }

    /**
     * 删除收录审核
     */


	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(inclusionExamineService.deleteInclusionExamineByIds(ids));
    }

    /**
     * 修改审核状态
     * @param id
     * @param status
     * @return
     */
    @GetMapping(value = "/updateStatus")
    public AjaxResult updateStatus(String  id, String  status)
    {
        return toAjax(inclusionExamineService.updateStatus(id,status));
    }



    /**
     * 审核收录
     */
    @PostMapping("/examine")
    public AjaxResult examine(@RequestBody InclusionExamine inclusionExamine) throws Exception {
        return toAjax(inclusionExamineService.examine(inclusionExamine));
    }


    @GetMapping(value = "/getExamineStatus/{projectId}")
    public AjaxResult getExamineStatus(@PathVariable("projectId") String projectId)
    {
        return success(inclusionExamineService.getExamineStatus(projectId));
    }
}
